var a = require("../export.js");

Page({
    data: {
        usercard: {},
        isShowLoading: !1,
        hasMore: !0,
        is_load_more: !0,
        tabIndex: 0,
        datas: [],
        options: {},
        pageNumber: 1,
        limit: 4,
        expried: 0,
        used: 0,
        valid: 0,
        cardInfo: !0,
        mycard: {},
        daodi: 0
    },
    onLoad: function(a) {
        this.init(a), this.countNum(a);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.asonPullDownRefresh();
    },
    asonPullDownRefresh: function() {
        this.setData({
            datas: [],
            pageNumber: 1,
            hasMore: !0,
            is_load_more: !0,
            daodi: 0
        });
        var t = {
            hasMore: this.data.hasMore,
            pageNumber: this.data.pageNumber,
            limit: this.data.limit,
            search: []
        };
        this.list(t), a.dg.stopPullDownRefresh();
    },
    onReachBottom: function() {},
    init: function(a) {
        a = {
            hasMore: this.data.hasMore,
            pageNumber: this.data.pageNumber,
            limit: this.data.limit,
            search: []
        }, this.list(a);
    },
    list: function(t) {
        var e = this;
        if (!t.hasMore) return this.setData({
            isShowLoading: !1
        }), !1;
        var i = {};
        i.type = this.data.tabIndex, i.pagesize = t.pageNumber, i.pagenum = t.limit, a.requestUtil.post(a._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/mycardList.html", i, function(i) {
            var o = e.data.usercard;
            0 != (i = i || []).length ? (0, a._)(i).map(function(a) {
                return e.setData({
                    daodi: 1
                }), a;
            }) : e.setData({
                daodi: 0
            }), o = 1 == t.pageNumber ? i || [] : o.concat(i || []), e.setData({
                isShowLoading: !1,
                hasMore: !(i.length < e.data.limit),
                pageNumber: t.pageNumber + 1,
                usercard: o
            });
        }, this, {
            isShowLoading: !1
        }), console.log(this.data);
    },
    allcard: function(a) {
        var t = parseInt(a.currentTarget.dataset.tabIndex);
        this.setData({
            tabIndex: t
        }), this.setData({
            is_load_more: !0,
            pageNumber: 1,
            datas: []
        }), this.countNum(this.data.options), this.onPullDownRefresh(1);
    },
    countNum: function(t) {
        var e = this;
        a.requestUtil.post(a._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/mycardCount.html", t, function(a) {
            e.setData({
                expried: a.expried,
                used: a.used,
                valid: a.valid
            });
        });
    },
    goinfo: function(t) {
        var e = this, i = {};
        i.id = t.currentTarget.dataset.id, 0 == t.currentTarget.dataset.tabIndex && a.requestUtil.post(a._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/mycardInfo.html", i, function(a) {
            e.setData({
                cardInfo: !1,
                mycard: a
            });
        });
    },
    cardHide: function() {
        this.setData({
            cardInfo: !0
        });
    }
});